﻿Public Class ctrlDGVCuaHang
    Event ChonCuaHang(cuaHang As tbCuaHang)
    Private Sub bsCuaHang_CurrentChanged(sender As Object, e As EventArgs) Handles bsCuaHang.CurrentChanged
        If bsCuaHang.Current IsNot Nothing Then
            RaiseEvent CuaHangThayDoi(bsCuaHang.Current)
        End If
    End Sub

    Private Sub bsCuaHang_ListChanged(sender As Object, e As System.ComponentModel.ListChangedEventArgs) Handles bsCuaHang.ListChanged
        lblSoDong.Text = bsCuaHang.Count.ToString + " cửa hàng."
    End Sub

    Private Sub dgvCuaHang_CellValueNeeded(sender As Object, e As DataGridViewCellValueEventArgs) Handles dgvCuaHang.CellValueNeeded
        If e.RowIndex >= 0 AndAlso e.ColumnIndex = Me.STT.Index Then
            e.Value = e.RowIndex + 1
        End If
    End Sub

    Event CuaHangThayDoi(cuaHang As tbCuaHang)
    Private Sub dgvCuaHang_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvCuaHang.CellDoubleClick
        If bsCuaHang.Current IsNot Nothing Then
            RaiseEvent ChonCuaHang(bsCuaHang.Current)
        End If
    End Sub

    Private Sub btnIn_Click(sender As Object, e As EventArgs) Handles btnIn.Click
        If bsCuaHang.Count > 0 Then

        End If
    End Sub

    Event ThemCuaHang()
    Private Sub ThêmCửaHàngToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ThêmCửaHàngToolStripMenuItem.Click
        RaiseEvent ThemCuaHang()
    End Sub

    Event SuaCuaHang()
    Private Sub SửaCửaHàngToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SửaCửaHàngToolStripMenuItem.Click
        RaiseEvent SuaCuaHang()
    End Sub

    Event XoaCuaHang()
    Private Sub XoáCửaHàngToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles XoáCửaHàngToolStripMenuItem.Click
        RaiseEvent XoaCuaHang()
    End Sub

    Private Sub InDanhSáchToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles InDanhSáchToolStripMenuItem.Click
        btnIn_Click(Nothing, Nothing)
    End Sub
End Class
